//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class CVector {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CVector(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CVector obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CVector(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setX(float value) {
    nelmiscJNI.CVector_x_set(swigCPtr, this, value);
  }

  public float getX() {
    return nelmiscJNI.CVector_x_get(swigCPtr, this);
  }

  public void setY(float value) {
    nelmiscJNI.CVector_y_set(swigCPtr, this, value);
  }

  public float getY() {
    return nelmiscJNI.CVector_y_get(swigCPtr, this);
  }

  public void setZ(float value) {
    nelmiscJNI.CVector_z_set(swigCPtr, this, value);
  }

  public float getZ() {
    return nelmiscJNI.CVector_z_get(swigCPtr, this);
  }

  public static CVector getNull() {
    long cPtr = nelmiscJNI.CVector_Null_get();
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public static CVector getI() {
    long cPtr = nelmiscJNI.CVector_I_get();
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public static CVector getJ() {
    long cPtr = nelmiscJNI.CVector_J_get();
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public static CVector getK() {
    long cPtr = nelmiscJNI.CVector_K_get();
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public CVector() {
    this(nelmiscJNI.new_CVector__SWIG_0(), true);
  }

  public CVector(float _x, float _y, float _z) {
    this(nelmiscJNI.new_CVector__SWIG_1(_x, _y, _z), true);
  }

  public CVector(CVector v) {
    this(nelmiscJNI.new_CVector__SWIG_2(CVector.getCPtr(v), v), true);
  }

  public CVector addSelf(CVector v) {
    return new CVector(nelmiscJNI.CVector_addSelf(swigCPtr, this, CVector.getCPtr(v), v), false);
  }

  public CVector subSelf(CVector v) {
    return new CVector(nelmiscJNI.CVector_subSelf(swigCPtr, this, CVector.getCPtr(v), v), false);
  }

  public CVector mulSelf(float f) {
    return new CVector(nelmiscJNI.CVector_mulSelf(swigCPtr, this, f), false);
  }

  public CVector divSelf(float f) {
    return new CVector(nelmiscJNI.CVector_divSelf(swigCPtr, this, f), false);
  }

  public CVector add(CVector v) {
    return new CVector(nelmiscJNI.CVector_add(swigCPtr, this, CVector.getCPtr(v), v), true);
  }

  public CVector sub(CVector v) {
    return new CVector(nelmiscJNI.CVector_sub__SWIG_0(swigCPtr, this, CVector.getCPtr(v), v), true);
  }

  public CVector mul(float f) {
    return new CVector(nelmiscJNI.CVector_mul__SWIG_0(swigCPtr, this, f), true);
  }

  public CVector div(float f) {
    return new CVector(nelmiscJNI.CVector_div(swigCPtr, this, f), true);
  }

  public CVector sub() {
    return new CVector(nelmiscJNI.CVector_sub__SWIG_1(swigCPtr, this), true);
  }

  public float mul(CVector v) {
    return nelmiscJNI.CVector_mul__SWIG_1(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public float norm() {
    return nelmiscJNI.CVector_norm(swigCPtr, this);
  }

  public float sqrnorm() {
    return nelmiscJNI.CVector_sqrnorm(swigCPtr, this);
  }

  public void normalize() {
    nelmiscJNI.CVector_normalize(swigCPtr, this);
  }

  public CVector normed() {
    return new CVector(nelmiscJNI.CVector_normed(swigCPtr, this), true);
  }

  public void set(float _x, float _y, float _z) {
    nelmiscJNI.CVector_set(swigCPtr, this, _x, _y, _z);
  }

  public boolean isEqual(CVector v) {
    return nelmiscJNI.CVector_isEqual(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public boolean notEqual(CVector v) {
    return nelmiscJNI.CVector_notEqual(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public boolean isNull() {
    return nelmiscJNI.CVector_isNull(swigCPtr, this);
  }

  public boolean lt(CVector v) {
    return nelmiscJNI.CVector_lt(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public void sphericToCartesian(float r, float theta, float phi) {
    nelmiscJNI.CVector_sphericToCartesian(swigCPtr, this, r, theta, phi);
  }

  public void cartesianToSpheric(SWIGTYPE_p_float r, SWIGTYPE_p_float theta, SWIGTYPE_p_float phi) {
    nelmiscJNI.CVector_cartesianToSpheric(swigCPtr, this, SWIGTYPE_p_float.getCPtr(r), SWIGTYPE_p_float.getCPtr(theta), SWIGTYPE_p_float.getCPtr(phi));
  }

  public void minof(CVector a, CVector b) {
    nelmiscJNI.CVector_minof(swigCPtr, this, CVector.getCPtr(a), a, CVector.getCPtr(b), b);
  }

  public void maxof(CVector a, CVector b) {
    nelmiscJNI.CVector_maxof(swigCPtr, this, CVector.getCPtr(a), a, CVector.getCPtr(b), b);
  }

  public void serial(IStream f) {
    nelmiscJNI.CVector_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public String asString() {
    return nelmiscJNI.CVector_asString(swigCPtr, this);
  }

  public String toString_c() {
    return nelmiscJNI.CVector_toString_c(swigCPtr, this);
  }

}
